import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import BasicLayout from "~/layout/BasicLayout.vue";
import { homeRoute } from "./modules/home";
import { testRoute } from "./modules/test";

const constantRoutes: Array<RouteRecordRaw> = [
	{
		path: "/login",
		name: "login",
		component: () => import("~/views/login/index.vue"),
		meta: {
			title: "登录",
			noAddTag: true,
		},
	},
	{
		path: "/404",
		name: "404",
		component: () => import("~/views/errorPage/404.vue"),
		meta: {
			noAddTag: true,
		},
	},
	{
		path: "/:pathMatch(.*)",
		redirect: "/404",
	},
];

export const asyncRoutes: Array<RouteRecordRaw> = [homeRoute, testRoute];
const router = createRouter({
	history: createWebHistory(`${import.meta.env.VITE_APP_PREFIX}/`),
	routes: [...asyncRoutes, ...constantRoutes],
	scrollBehavior: function () {
		return { left: 0, top: 0 };
	},
});

export default router;
